layui.extend({
	 selectN: '{/}/plugins/layui-select-ext/selectN',
	 selectM: '{/}/plugins/layui-select-ext/selectM'
});
layui.define([ 'form', 'laydate', 'table','articleApi','selectN'], function(exports) {
    var form = layui.form;
    var selectN = layui.selectN;
    var articleApi = layui.articleApi;
    var index = layui.index;
    var view = {
        init:function(){
	        Lib.initGenrealForm($("#updateForm"),form);
	        this.initSubmit();
	        Common.initKindedit(".kindEditor");
	        this.initSelectArea();
        },
        initSubmit:function(){
            $(".updateButton").click(function(){
                form.on('submit(form)', function(){
                    articleApi.updateCoreArticle($('#updateForm'),function(){
                       parent.window.dataReload();
                       Common.info("更新成功");
                       Lib.closeFrame();
                    });
                });
            });
            $(".updateButton-cancel").click(function(){
                Lib.closeFrame();
            });
        },
       initSelectArea:function() {
        if ($("#area").length > 0) {
//无限级分类-所有配置
      	    var catIns2 = selectN({
      	      //元素容器【必填】
      	      elem: '#area'
      	      //候选数据【必填】
      	      ,url: "/area/tree.json"
      	      //设置了长度
      	      ,width:null
      	      ,classNames:"lay-col-md3"
      	      //默认值
      	      ,selected: ["370000000000","370100000000","370114000000","370114002000"]
      	      ,name:""
      	      //为真只取最后一个值
      	      ,last:true
      	      //空值项提示，可设置为数组['请选择省','请选择市','请选择县']
      	      ,tips: ['请选择省','请选择市','请选择区县']
   			  //事件过滤器，lay-filter名 不设置与选择器相同(去#.)
      	      ,filter: ''
   		  //input的name 不设置与选择器相同(去#.)
   		  //数据分隔符
   		  ,delimiter: ','
   		  //数据的键名
   		  ,field:{idName:'areaCode',titleName:'name',childName:'children'}
   		  //表单区分 form.render(type, filter); 为class="layui-form" 所在元素的 lay-filter="" 的值
   		  ,formFilter: null
      	      ,search:true
      	      ,parentField:"areaCode"
      	      ,parentParamName:"parentAreaCode"
      	      ,selectNames:["provinceCode","cityCode","countryCode"]
      	    });
         }
        }

    }
    
    
    
    exports('edit',view);
	
});